<?php
/**
 * article table
 * 'title', 'short_title', 'descrition', 'image_id', 'image_id_list', 'content', 'uid'
 *
 */
namespace backend\models;

use Yii;
use yii\db\ActiveRecord;
class Product extends ActiveRecord{
	public function scenarios(){
		return [
			'create' => ['name', 'stime', 'etime', 'create_time', 'status', 'description', 'image_id'],

			'update' => ['name', 'stime', 'etime', 'status'],
		];
	}

	public function rules(){

		return [
			[['name', 'cid', 'stime', 'etime', 'status', 'description'], 'required'],
			['name', 'string', 'min' => 1, 'max' => 20],
			['create_time', 'default', 'value' => time(), 'skipOnEmpty' => false,],
			['image_id', 'exist', 'targetClass' => 'backend\models\Files', 'targetAttribute' => ['image_id'=> 'id']],
		];
	}

	public function toMyData(){
		$this->stime = strtotime($this->stime);
		$this->etime = strtotime($this->etime);
		$this->description = $this->description;
	}	
}